************************************************************************************************
*	Replication files for Turnbull-Dugarte (2024) 											   *
*	"Far from the (Conservative) tree? Sexuality and intergenerational partisan preferences"   *
************************************************************************************************
use hereditary.dta, clear

***TABLE 1***

reg perfectmatch2 i.sexminority i.sex c.age c.agesq i.nonwhite i.degree c.polAttention [pweight=wt], hc3
reg perfectmatch2 i.sexminority i.partyhome_singles i.parentmissing i.sex c.age c.agesq i.nonwhite i.degree c.polAttention [pweight=wt], hc3
reg perfectmatch2 i.sexminority##i.partyhome_singles i.parentmissing i.sex c.age c.agesq i.nonwhite i.degree c.polAttention [pweight=wt], hc3


***FIGURE 3***
margins sexminority, at(partyhome_singles=(0(1)2)) post
estimates store m1

***FIGURE 5***
reg distance_home i.sexminority##partyhome_singles i.parentmissing i.sex c.age c.agesq i.nonwhite i.degree c.polAttention [pweight=wt], hc3
margins, dydx(sexminority) at(partyhome_singles=(0 1)) post


***TABLE 2****
reg perfectmatch2 i.sexuality##i.partyhome_singles i.parentmissing i.sex c.age c.agesq i.nonwhite i.degree c.polAttention [pweight=wt] if sexuality!=4, hc3
margins sexuality, at(partyhome_singles=(0 1 2)) post
estimates store m_bi 

reg perfectmatch2 i.sexuality##i.partyhome_singles i.parentmissing i.sex c.age c.agesq i.nonwhite i.degree c.polAttention [pweight=wt] if sexuality!=4, hc3
margins, dydx(2.sexuality) at(partyhome_singles=(0 1 2)) post
estimates store m_bi2

reg perfectmatch2 i.sexuality##i.partyhome_singles i.parentmissing i.sex c.age c.agesq i.nonwhite i.degree c.polAttention [pweight=wt] if sexuality!=4, hc3
margins, dydx(3.sexuality) at(partyhome_singles=(0 1 2)) post
estimates store m_bi3

reg perfectmatch2 ib(2).sexuality##i.partyhome_singles i.parentmissing i.sex c.age c.agesq i.nonwhite i.degree c.polAttention [pweight=wt] if sexuality!=4, hc3
margins, dydx(3.sexuality) at(partyhome_singles=(0 1 2)) post
estimates store m_bi4



***TABLE 3***
reg perfectmatch2 i.sexminority##partyhome_singles##i.sex i.parentmissing i.degree c.age c.agesq i.nonwhite c.polAttention [pweight=wt], hc3
margins sexminority, at(partyhome_singles=(0 1 2) sex=(0 1)) post
estimates store gen1

reg perfectmatch2 i.sexminority##partyhome_singles##i.sex i.parentmissing i.degree c.age c.agesq i.nonwhite c.polAttention [pweight=wt], hc3
margins, dydx(sexminority) at(partyhome_singles=(0 1 2) sex=(0 1)) post
estimates store gen2


////////APPENDIX MATERIAL

**TABLE A7***

reg perfectmatch2 i.sexminority##partyhome_singles##i.sex i.parentmissing i.degree c.age c.agesq i.nonwhite c.polAttention [pweight=wt], hc3

**TABLE A8***
reg perfectmatch2 i.sexminority##partyhome_singles##i.degree i.sex i.parentmissing c.age c.agesq i.nonwhite c.polAttention [pweight=wt], hc3

**TABLE A9***
reg perfectmatch2 i.sexminority##partyhome_singles##c.polAttention i.degree i.sex i.parentmissing c.age c.agesq i.nonwhite [pweight=wt], hc3


**TABLE A1O***
reg perfectmatch2 i.sexuality##i.partyhome_singles i.parentmissing i.sex c.age c.agesq i.nonwhite i.degree c.polAttention [pweight=wt] if sexuality!=4, hc3

**TABLE A11***
reg PTVparenthome i.sexminority##partyhome_singles i.parentmissing i.sex c.age c.agesq i.nonwhite i.degree c.polAttention [pweight=wt], hc3
reg likeparenthome i.sexminority##partyhome_singles i.parentmissing i.sex c.age c.agesq i.nonwhite i.degree c.polAttention [pweight=wt], hc3
reg distance_home i.sexminority##partyhome_singles i.parentmissing i.sex c.age c.agesq i.nonwhite i.degree c.polAttention [pweight=wt], hc3


**TABLE A12***
reg lr_scale i.sexminority##i.partyhome_singles i.parentmissing i.sex c.age c.agesq i.nonwhite i.degree c.polAttention [pweight=wt], hc3
reg al_scale i.sexminority##i.partyhome_singles i.parentmissing i.sex c.age c.agesq i.nonwhite i.degree c.polAttention [pweight=wt], hc3
reg leftRight i.sexminority##i.partyhome_singles i.parentmissing i.sex c.age c.agesq i.nonwhite i.degree c.polAttention [pweight=wt], hc3




***FIGURE A4***
use hereditary_panel.dta, clear

reg lgb_w20 lgb_w19 i.partyIdW19 c.ageW19 i.gender i.p_edlevelW19 c.leftRightW19 [pweight= wt_new_W20], hc3
outreg2 using egant1.doc, replace dec(2)
coefplot, keep(*.partyIdW19) xline(0) mlabel mlabsize(vsmall) mlabformat(%9.2f) mlabposition(12) title("t-1") caption(Effect of Party ID controlling for LGB-ID at t-1 (N=11472))
graph save p1.gph, replace
graph export eganRep_margins.png, replace

reg lgb_w20 lgb_w18 i.partyIdW18 c.ageW18 i.gender i.p_edlevelW18 c.leftRightW18 [pweight= wt_new_W20], hc3
outreg2 using egant2.doc, replace dec(2)
coefplot, keep(*.partyIdW18) xline(0) mlabel mlabsize(vsmall) mlabformat(%9.2f) mlabposition(12) title("t-2") caption(Effect of Party ID controlling for LGB-ID at t-2 (N=12052))
graph save p2.gph, replace
graph export eganRep_margins_t2.png, replace

reg lgb_w20 lgb_w17 i.partyIdW17 c.ageW17 i.gender i.p_edlevelW17 c.leftRightW17 [pweight= wt_new_W20], hc3
outreg2 using egant3.doc, replace dec(2)
coefplot, keep(*.partyIdW17) xline(0) mlabel mlabsize(vsmall) mlabformat(%9.2f) mlabposition(12) title("t-3)") caption(Effect of Party ID controlling for LGB-ID at t-3 (N=11196))
graph export eganRep_margins_t3.png, replace
graph save p3.gph, replace

reg lgb_w20 lgb_w10 i.partyIdW10 c.ageW10 i.gender i.p_edlevelW10 c.leftRightW10 [pweight= wt_new_W20], hc3
outreg2 using egant4.doc, replace dec(2)
coefplot, keep(*.partyIdW10) xline(0) mlabel mlabsize(vsmall) mlabformat(%9.2f) mlabposition(12) title("t-10") caption(Effect of Party ID controlling for LGB-ID at t-10 (N=6437))
graph export eganRep_margins_t4.png, replace
graph save p4.gph, replace

graph combine p1.gph p2.gph p3.gph p4.gph, xcommon ycommon col(1)

